package com.ricky;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by bgt on 2018/5/1.
 */
// 属性的前缀 比如我里面的文件是learn.user 则只@value("${user}")即可获取learn.user的value
@ConfigurationProperties(prefix = "learn")
@Component
public class JDBCProperties implements InitializingBean{

    private String user,pwd;
    private List<String> host;

    public List<String> getHost() {
        return host;
    }

    public void setHost(List<String> host) {
        this.host = host;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    @Override
    public String toString() {
        return "JDBCProperties{" +
                "user='" + user + '\'' +
                ", pwd='" + pwd + '\'' +
                ", host=" + host +
                '}';
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("我注入成功了呢"+this.toString());
    }
}
